<template>
    <div class="home">
        <h1 class="title">浙江省市场监督管理局</h1>
        <div class="desc">MARKET SUPERVISION ADMINISTRATION OF ZHEJIANG</div>
        <div class="search">
            <Inputs @change='change' />
        </div>
        <div class="content">
            <div class="content_title collection_content_title">
                <div class="icontitle">
                    <img class="icon" src="../assets/col.png" alt="" />
                    <span>我的收藏</span>
                </div>

                <span class="more" @click="handMoreClick">更多</span>
            </div>
            <div class="hotspot_list">
                <div class="item" :key="index" v-for="(item,index) in collection_list">
                    <span class="title_name">{{ item.title }}</span> {{ item.content }}
                </div>
            </div>
        </div>

        <div class="content hotspot">
            <div class="content_title">
                <div class="icontitle">
                    <img class="icon" src="../assets/hot.png" alt="" />
                    <span>热点知识</span>
                </div>
            </div>
            <div class="hotspot_list">
                <div class="item" :key="index" v-for="(item,index) in collection_list">
                    <span class="title_name">{{ item.title }}</span> {{ item.content }}
                </div>
            </div>
        </div>
    </div>
</template>

<script>
import request from "@/utils/request";
import Inputs from '@/components/Inputs.vue'
export default {
  name: "Home",
  data() {
    return {
      value: "",
      hotspot_list: [],
      collection_list: [],
    };
  },
  components: {
    Inputs
  },
  created() {
    this.getList();
    this.getCollectionList();
  },
  methods: {
    async getList() {
      const res = await request.get("/hotspot/list");
      this.hotspot_list = res.data;
    },
    async getCollectionList() {
      const res = await request.get("/collection/list");
      this.collection_list = res.data;
    },
    handMoreClick() {
      this.$router.push({ path: "/MyCollection" });
    },
    change(res) { 
      console.log('====================================');
      console.log(res);
      console.log('====================================');
      this.$router.push('/Cange/'+res)
    }
  },
};
</script>

<style scoped>
.home {
    width: 50%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-items: center;
    align-items: center;
    margin: 0 auto;
}

.title {
    color: #0400bf;
    font-size: 28px;
    font-weight: 900;
    text-align: center;
    margin-top: 50px;
}
.desc {
    text-align: center;
}
.search {
    width: 100%;
    margin: 20px auto;
}
.content {
    width: 100%;
}
.hotspot {
    margin-top: 20px;
}
.content_title {
    text-align: left;
    font-size: 21px;
    font-weight: 600;
    margin-bottom: 15px;
}
.collection_content_title {
    display: flex;
    justify-content: space-between;
}
.more {
    font-size: 14px;
    color: #2b79fe;
    cursor: pointer;
}
.hotspot_list {
    display: flex;
    flex-flow: row wrap;
    justify-content: space-between;
}
.item {
    width: 48%;
    margin-top: 10px;
}
.title_name {
    color: #999;
}
.icontitle {
    display: flex;
    align-items: center;
    vertical-align: middle;
}
.icon {
    width: 30px;
    height: 30px;
    margin-right: 5px;
}
.el-input >>> .el-input__inner {
    border-radius: 20px;
}
</style>
